package com.nekonomics.lakehouse.dim
import com.nekonomics.lakehouse.common.FlinkRunner._
import com.nekonomics.lakehouse.common.util.SqlUtil._


object MerchantDIm {
  def main(args: Array[String]): Unit = {
    implicit val config: SqlRunnerConfig = SqlRunnerConfig(groupId = "merchant_dim", port = 8082, ckp=true)
    runSql { (_, tableEnv) =>
      tableEnv.executeSql(
        sql"""
             |CREATE TABLE IF NOT EXISTS my_catalog.dim.merchant_dim (
             |  merchant_id BIGINT PRIMARY KEY NOT ENFORCED,
             |  name STRING,
             |  user_id BIGINT,
             |  verified BOOLEAN,
             |  created_at TIMESTAMP(3),
             |  is_deleted BOOLEAN
             |)
             |""".stripMargin
      )

      tableEnv.executeSql(
        sql"""
             |INSERT INTO dim.merchant_dim
             |SELECT
             |  id AS merchant_id,
             |  name,
             |  user_id,
             |  verified,
             |  created_at,
             |  is_deleted
             |FROM ods.merchant_ods
             |WHERE is_deleted = false;
             |""".stripMargin
      )






    }













  }





}
